package com.zyd.blog.personal.service.impl;

import com.zyd.blog.personal.service.UserInfoService;
import com.zyd.blog.personal.service.UserSimpleInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户简单信息业务逻辑层
 * @author mfy
 */
@Service
public class UserSimpleInfoServiceImpl implements UserSimpleInfoService {

    @Resource
    private UserInfoService userInfoService;

    @Override
    public Map<String,Object> getUserSimpleInfo(Long userId){
        Map<String,Object> map = new HashMap<>(16);
        //  获得用户基本信息
        List<Map<String,Object>> userInfo = userInfoService.getUserInfo(userId);
        if(userInfo.size() > 0){
            map.put("headPicture",userInfo.get(0).get("headPicture"));
            map.put("nickname",userInfo.get(0).get("nickname"));
            map.put("sex",userInfo.get(0).get("sex"));
            map.put("id",userInfo.get(0).get("userId"));
            return map;
        }
        return new HashMap<> (0);
    }
}
